// 数据存储方式 + 数据行为  构成数据结构
// 泛型 类型传参
// 约束内部的类型
class TreeNode<T> {
    val: T;
    left: TreeNode<T> | null;
    right: TreeNode<T> | null;
    constructor(val: T, left: TreeNode<T> | null = null,
        right: TreeNode<T> | null = null) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
class BinarySearchTree<T> {
    private root: TreeNode<T> | null = null;

    insert(val: T):void {
        const newNode = new TreeNode<T>(val)
        if (this.root = null) {
            this.root = newNode
        }
    }
    private insertNode(node: TreeNode<T>, newNode: TreeNode<T>) {
        if (newNode.val < node.val) {
            if (node.left === null) {
                node.left = newNode
            } else {
                this.insertNode(node.left, newNode)
            }
        }
    }
}
const bst = new BinarySearchTree<number>()
bst.insert(1)